﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using BusinessObjects.BO_GetObjects;

/// <summary>
/// Summary description for Admin
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class Admin : System.Web.Services.WebService
{

    public Admin()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }
    [WebMethod]
    public bool Members_Vip()
    {
        return true;
    }
    //categories order
    [WebMethod]
    public bool CateOrder(string id)
    {
        return BO_portal_categories.Order(id);
    }
    //----Admin module----
    [WebMethod]
    public bool AdminModuleOrders(string ids)
    {
        try
        {
            return BO_cms_admin_modules.Order(ids);
        }
        catch (Exception)
        {

            throw;
        }
    }
    [WebMethod]
    public bool AMOrder(string ids)
    {
        return BO_cms_admin_modules.Order(ids);
    }

    //----Advertising----
    [WebMethod]
    public bool ADVOrder(string id, int module)
    {
        return BO_portal_ads_pictures.Order(id, module);
    }
    //----Categories----
    //----Modules----
    [WebMethod]
    public bool MDOrder(string id, int category, int location)
    {
        return BO_portal_modules.Order(id, location, category);
    }
    //----OnlineSupport----
    [WebMethod]
    public bool OSOrder(string id, int module)
    {
        return BO_cms.Join_Tables_Order(id, "FK_portal_online_support_portal_modules", module);
    }

    //---- Weblink----
    [WebMethod]
    public bool WLOrder(string id, int module)
    {
        return BO_cms.Join_Tables_Order(id, "FK_portal_weblinks_portal_modules", module);
    }

    //---- Partner----
    [WebMethod]
    public bool PNOrder(string id, int module)
    {
        return BO_cms.Join_Tables_Order(id, "PORTAL_PARTNERS/PORTAL_MODULES", module);
    }
    [WebMethod]
    public bool SendFAQ(string name, string email, string phone, string detail, string mailto)
    {
        DigiLib.MailUtils mail = new DigiLib.MailUtils("FAQs", "1 câu h?i m?i t? DIGIWEB.VN", "<p><h3>Ngu?i g?i: </h3>" + name
                    + "</p><p><h3>S? di?n tho?i: </h3>" + phone + "</p><p><h3>Email: </h3>" + email + "</p><p>" + detail + "</p>", mailto, true, true);
        return mail.Send();
        //if (BO_portal_articles.Insert(5, 1, "", "", "", "", "", detail, "", "", "", "", "", "", "", "", "", "", 0, 0, 0, 0, false, false, 1, 1, DateTime.Now, DateTime.Now, "", DateTime.Now, name, DateTime.Now, "", -1).Equals("0"))
        //    return false;
        //else
        //    return true;
    }
    [WebMethod]
    public bool SendContact(string name, string email, string phone, string detail, string address)
    {
        if (BO_portal_contact_us.Insert(name, email, "", "", "", address, "", detail, false, DateTime.Now, true).Equals("0"))
            return false;
        else
        {
            DigiLib.MailUtils mail = new DigiLib.MailUtils("Liên h?", "1 liên h? m?i t? DIGIWEB.VN", "<p><h3>Ngu?i g?i: </h3>" + name
                    + "</p><p><h3>S? di?n tho?i: </h3>" + phone + "</p><p><h3>Email: </h3>" + email + "</p><p>" + detail + "</p>", "chieunt@digicorp.vn", true, true);
            return mail.Send();
        }
    }
    [WebMethod]
    public string AddVote(int question_id, int answer_id)
    {
        //if (!string.IsNullOrEmpty(Session["vote"].ToString()))
        //{
        string strReturn = BO_portal_survey_results.Insert(answer_id, 0, DateTime.Now, "", DateTime.Now, "", true);
        if (strReturn == "0")
        {
            return "Có lỗi trong quá trình gửi! xin thử lại!";
        }
        else
        {
            return "Cảm ơn bạn đã gửi ý kiến!";
        }
        //}
        //return "Có lỗi trong quá trình gửi! xin thử lại!";
    }
}
